package com.mgface.framework.springcloud.feign;

import com.mgface.framework.springcloud.entity.User;
import com.mgface.framework.springcloud.hystrixfactory.HystrixClientFactory;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author wanyuxiang
 * @version 1.0
 * @project ms-hystrix
 * @create 2017-04-11 16:01
 **/

//fallback和fallbackFactory只能二择其一
//@FeignClient(name="ms-provider-user",fallback = HystrixClientFallback.class)
@FeignClient(name="ms-provider-user",fallbackFactory = HystrixClientFactory.class)
public interface UserFeignClient {
    /**
     * http://192.168.1.101:7912/health 出现以下的信息，需要多次访问这个http://192.168.1.101:7912/movie/1才能达到效果，应该是根据访问次数有关系
     * "hystrix": {
     * "status": "CIRCUIT_OPEN",
     * "openCircuitBreakers": [
     * "ms-provider-user::UserFeignClient#findById(Long)"
     * ]
     }
     */
    @RequestMapping(value = "/simple/{id}",method = RequestMethod.GET)
    public User findById(@PathVariable("id")Long id);
}
